app.service('chainGoodsAddService',['$http','$q','utilService','$cookies',function($http,$q,utilService,$cookies){
    var _this_=this;

    _this_.importGoods= function ($scope,id) {
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain+"/chain/goods/import",
            data:{id:id}
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    _this_.batchImportGoods=function($scope){
        var ids=new Array();
        for(var i=0;i<$scope.selected.length;i++){
            ids.push($scope.selected[i].id);
        }
        var deferred=$q.defer();
        utilService.api({
            url:$scope.app.domain+"/chain/goods/batch/import",
            data:{ids:ids,sessionId:$cookies.sessionId},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

}]);